#pragma once
#include "global_var.h"
#include "Scene.h"
#include "SceneManager.h"
#include "ScreenText.h"
#include "Object2D.h"
#include "Image.h"
#include "Sprite.h"
#include <list>
using namespace std;
using namespace Pulpy;

//includes
//	class LeaderBoard
//	class HighScorePage : public Scene
//	class ScoreBoard	: public Scene

class LeaderBoard
{ //Leader board system
private:
	LeaderBoard(void);
	int P1_Score;	//For in-game score checking
	int P2_Score;	//For in-game score checking

	list<pair<string, int>> ScoreList;
					//LeaderBoard score from file

public:
	static LeaderBoard getInstance()
	{
		static LeaderBoard s_instance;
		return s_instance;
	}
	void SaveFile(void);

	void P1_AddScore(void) { ++P1_Score; };
	void P2_AddScore(void) { ++P2_Score; };
	int P1_GetScore(void) { return P1_Score; };
	int P2_GetScore(void) { return P2_Score; };

	list<pair<string,int>> getScoreList(void) { return ScoreList; };
};

class HighScorePage : public Scene
{ //High Score Page Scene
private:
	list<pair<string, int>> ScoreList;

	Object2D Background;
	Object2D Continue;
	TextureImage SceneImages[2];

public:
	HighScorePage();
	~HighScorePage();

	void draw();
	void update();
	void reset();
	void freeResource();
	void loadResource();
	void handleKeyboard(int key, int x, int y);
	void handleKeyboardUp(int key, int x, int y);
	void handleKeyboardSpecial(int key, int x, int y);
	void getMid(int &x, int &y);
	void handleMouseClick(int button, int state, int x, int y);
	void handleMouseMove(int x, int y);
};

class ScoreBoard : public Scene
{ //In-game HighScore Scene
private:
	Object2D Background;
	Object2D Continue;
	Object2D P1Score_Word;						// To print the word "P1 Score:"
	Object2D P1Score_Tenth;						// To print tenth position of the score for Player 1
	Object2D P1Score_One;							// To print one position of the score for Player 1
	Object2D P2Score_Word;						// To print the word "P2 Score:"
	Object2D P2Score_Tenth;						// To print tenth position of the score for Player 2
	Object2D P2Score_One;

	Sprite * Numbers[1];
	TextureImage ScoreWord[2];
	TextureImage Image_Background[2];
	
	int ScenePrevTime;

public:
	ScoreBoard();
	~ScoreBoard();

	void draw();
	void update();
	void reset();
	void freeResource();
	void loadResource();
	void handleKeyboard(int key, int x, int y);
	void handleKeyboardUp(int key, int x, int y);
	void handleKeyboardSpecial(int key, int x, int y);
	void getMid(int &x, int &y);
	void handleMouseClick(int button, int state, int x, int y);
	void handleMouseMove(int x, int y);
};